/**
 * 
 */
package com.laotou99.backjack.test;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Base64;
import java.util.zip.ZipInputStream;

import org.apache.commons.compress.compressors.lzma.LZMAUtils;
import org.apache.commons.compress.compressors.xz.XZUtils;

import com.laotou99.backjack.util.StringCompress;
import com.xiaoleilu.hutool.Hutool;
import com.xiaoleilu.hutool.lang.Base32;
import com.xiaoleilu.hutool.util.ZipUtil;

/**
 * @author wisdom
 *
 */
public class MainTest4 {
	
	String abc = "aIIIaaeeefDfggGHhtBBBewsdf";
	String stra1 = "adfasdfsdfasdfasdfewerqcasvadfasdf"
			+ "adfadsfasdfasdfasdfewefsasdfsadvsdva"
			+ "fasdfafewfedasfdsfddasfadssfadsf"
			+ "asdfasdfewefJ:IHLJKHUGIUHIHJBLHGUY"
			+ "JHLJHIUHKJHKJGGGIIUUHJJKafasdfsdfa"
			+ "fasdsdfasfeEWRWERVFASFDSAFsad"
			+ "adafdsfadfewfdsajklajdkfhasdfiausdfha"
			+ "dafdsfpudfnjakhdiuHIJHPIUHjdhfaldjfad"
			+ "adhfuhJLHLIUGYGUTGYOGOYGOYGOYHGYGUUPUhpy"
			+ "dafdufhuUIHPIUHJHLGYFITFIYGOYPHUIHOPUIHL"
			+ "DFADSFWEQEWRADSfasdvcbwefhtweegrFADSFAsd"
			+ "fadfahUHOIGOYGOGUYGBOBPUIBPUYGOYUHupiuhpufae";
	/**
	 * 
	 */
	public MainTest4() {

	}

	public void test5(){
		byte[] bba = new byte[1024];
		InputStream in = new ByteArrayInputStream(bba);
		ZipInputStream zis = new ZipInputStream(in);
	}
	
	public void test1(){
		String str2 = com.xiaoleilu.hutool.lang.Base64.encode(abc);
		System.out.println(str2);
		String str3 = com.xiaoleilu.hutool.lang.Base64.decodeStr(str2);
		System.out.println(str3);
	
	}

	public void test3(){
		
		String aaa = Base64.getEncoder().encodeToString(abc.getBytes());
		System.out.println(aaa);
		
		byte[] b1 = Base64.getDecoder().decode(aaa);
		String bbb= new String(b1);
		System.out.println(bbb); 
		
	}
	public void test2(){
		System.out.println(abc.length());
		byte[] b1=Base32.decode(abc);
		String str44 = Base32.decodeStr(abc);
		System.out.println(str44);
		System.out.println(Arrays.toString(b1));
		System.out.println(b1.length);
		
		String str2 = Base32.encode(b1);
		System.out.println(str2);
		
//		fast
//		Base64 b64 = new Base64();
//		b64.decodeFast(arg0)
	}
	
	public void test4()
	{String str1 = "adfasdfsdfasdfasdfewerqcasvadfasdf"
			+ "adfadsfasdfasdfasdfewefsasdfsadvsdva"
			+ "fasdfafewfedasfdsfddasfadssfadsf"
			+ "asdfasdfewefJ:IHLJKHUGIUHIHJBLHGUY"
			+ "JHLJHIUHKJHKJGGGIIUUHJJKafasdfsdfa"
			+ "fasdsdfasfeEWRWERVFASFDSAFsadfae";
		System.out.println(str1.length());
		System.out.println(Arrays.toString(str1.getBytes()));
		try {
			byte[] b1 = ZipUtil.gzip(str1.getBytes());
			System.out.println(Arrays.toString(b1));
			System.out.println(b1.length);
			byte[] b2 = ZipUtil.unGzip(b1);
			String str2 = new String(b2);
			System.out.println(str2);
		} catch (IOException e) { 
			e.printStackTrace();
		}
	}
	
	public void test6()
	{
		String str1 = "adfasdfsdfasdfasdfewerqcasvadfasdf"
				+ "adfadsfasdfasdfasdfewefsasdfsadvsdva"
				+ "fasdfafewfedasfdsfddasfadssfadsf"
				+ "asdfasdfewefJ:IHLJKHUGIUHIHJBLHGUY"
				+ "JHLJHIUHKJHKJGGGIIUUHJJKafasdfsdfa"
				+ "fasdsdfasfeEWRWERVFASFDSAFsadfae";
		System.out.println(str1.length());
		byte[] aa = Base32.decode(str1);
		String str1_1 = Base32.decodeStr(str1);
		System.out.println(str1_1);
		System.out.println(str1_1.length());
		System.out.println(Arrays.toString(aa));
		System.out.println(aa.length);
		String str2 = Base32.encode(aa);
		System.out.println(str2);
		String str3 = Base32.encode(str1_1);
		System.out.println(str3);
	}
	
	public void test7(){
		System.out.println(stra1.length());
		byte[] bb1 = StringCompress.compress(stra1);
		System.out.println(bb1.length);
		String str1 = StringCompress.decompress(bb1);
		System.out.println(str1);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		MainTest4 mt4 = new MainTest4();
		mt4.test7();
	}

}
